﻿Imports Mysoft.Map.Data
Imports System.Data

Partial Public Class Cwjk_BatchSet
    Inherits Mysoft.Map.Application.Security.AppPage

#Region " Web 窗体设计器生成的代码 "

    '该调用是 Web 窗体设计器所必需的。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents txtName As System.Web.UI.WebControls.TextBox

    '注意: 以下占位符声明是 Web 窗体设计器所必需的。
    '不要删除或移动它。
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
        '不要使用代码编辑器修改它。
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '设置默认值
        Dim sOpenRoot, sOperObject, sGUID As String

        sOpenRoot = Request.QueryString("openroot")
        sOperObject = Request.QueryString("operobject")

        If Request.QueryString("sguid") Is Nothing Then
            sGUID = "null"
        Else
            sGUID = Request.QueryString("sguid")
        End If

        If Trim(sOpenRoot) <> "" Then
            '设置页面信息
            SetMsg(sOpenRoot, sOperObject)

            If sGUID <> "null" Then
                Select Case sOperObject
                    Case "楼栋名称"
                        SetBldHsType(sGUID)
                        Exit Select

                    Case "房间信息"
                        SetRoomHsType(sGUID)
                        Exit Select
                End Select
            End If
        Else

        End If
    End Sub

    '设置楼栋的核算代码样式
    Private Function SetBldHsType(ByVal a_sGUID As String)

        Dim strProjCode As String = MyDB.GetDataItemString("SELECT TOP 1 ProjCode+';'+projname FROM p_project WHERE ProjGUID='" & a_sGUID & "'")
        Dim ArrVal() As String = strProjCode.Split(";")

        If ArrVal.Length = 2 Then
            txtNowCode.Text = ArrVal(0) & "-"
            txtRptCode.Text = ArrVal(0) & "."

            txtNowName.Text = ArrVal(1)
            txtRptName.Text = ArrVal(1).Replace("-", "")
        Else
            txtNowCode.Text = ""
            txtRptCode.Text = ""
            txtNowName.Text = ""
            txtRptName.Text = ""
        End If
    End Function

    '设置房间的核算代码样式
    Private Function SetRoomHsType(ByVal a_sGUID As String)
        Dim strSQL As String
        Dim dtTmp As DataTable

        strSQL = "SELECT TOP 1 ParentCode,BldCode,BldName FROM p_building WHERE BldGUID='" & a_sGUID & "'"
        dtTmp = MyDB.GetDataTable(strSQL)

        If dtTmp.Rows.Count > 0 Then
            txtNowCode.Text = dtTmp.Rows(0).Item("ParentCode").ToString & "-" & dtTmp.Rows(0).Item("BldCode").ToString & "-"
            txtRptCode.Text = dtTmp.Rows(0).Item("ParentCode").ToString & "." & dtTmp.Rows(0).Item("BldCode").ToString & "."
            txtNowName.Text = dtTmp.Rows(0).Item("BldName").ToString
            txtRptName.Text = dtTmp.Rows(0).Item("BldName").ToString
        Else
            txtNowCode.Text = ""
            txtRptCode.Text = ""
            txtNowName.Text = ""
            txtRptName.Text = ""
        End If
    End Function

    '设置页面信息
    Private Function SetMsg(ByVal a_sOpenRoot As String, ByVal a_sOperObject As String)
        If a_sOpenRoot = "HSXM" Then
            Select Case a_sOperObject
                Case "楼栋名称"
                    LblMsgCode.Text = "核算代码（项目编码+分区编码+楼栋编码）"
                    LblNowMsgCode.Text = "现项目编码："
                    LblRptMsgCode.Text = "替换项目编码："
                    LblMsgName.Text = "核算名称（项目名称+分区名称+楼栋名称）"
                    LblNowMsgName.Text = "现项目名称："
                    LblRptMsgName.Text = "替换项目名称："
                    LblMsgHs.Text = "替换核算类别："
                    txtHsType.Visible = True
                    Exit Select
                Case "房间信息"
                    LblMsgCode.Text = "核算代码（楼栋代码+房号）"
                    LblNowMsgCode.Text = "现楼栋代码："
                    LblRptMsgCode.Text = "替换楼栋代码："
                    LblMsgName.Text = "核算名称（楼栋名称+房号）"
                    LblNowMsgName.Text = "现楼栋名称："
                    LblRptMsgName.Text = "替换楼栋名称："
                    LblMsgHs.Text = "替换核算类别："
                    txtHsType.Visible = True
                    Exit Select

                Case "预约单"
                    LblMsgCode.Text = "核算代码（项目排号+预约单客户名称拼音首字）"
                    LblNowMsgCode.Text = ""
                    LblRptMsgCode.Text = ""
                    LblRptMsgCode.Enabled = False

                    LblMsgName.Text = "核算名称（预约单客户名称）"
                    LblNowMsgName.Text = ""
                    LblRptMsgName.Text = ""
                    LblRptMsgName.Enabled = False

                    LblMsgHs.Text = "替换核算类别："
                    txtHsType.Visible = True
                    Exit Select
            End Select
        End If
    End Function

End Class
